<?php
class Zend_View_Helper_ListSelects
{
    public function listSelects($view,$nameSelector,$dataSelects)
    {
        $strList = "<select name='$nameSelector' id='$nameSelector'>";

        $strList .= "<option value='0'>----------</option>";

        if(count($dataSelects) > 0)
        {
            foreach($dataSelects as $item)
            {
                if(!empty($view->obj->id))
                {
                    //if($item->id != $view->obj->id)
                    //{
                        if((!empty($view->obj->$nameSelector) && $item->id == $view->obj->$nameSelector)
                                || (!empty($view->obj->parent_id) && $item->id == $view->obj->parent_id))
                            $select = "selected";
                        else {
                            $select = "";
                        }

                        if($view->langType == 'vn')
                            $strList .=  "<option value='$item->id' $select>$item->name_vn</option>";
                        else
                            $strList .=  "<option value='$item->id' $select>$item->name_en</option>";
                    //}
                }
                else
                {
                    
                    if((!empty($view->obj->$nameSelector) && $item->id == $view->obj->$nameSelector)
                            || (!empty($view->obj->parent_id) && $item->id == $view->obj->parent_id))
                        $select = "selected";
                    else {
                        $select = "";
                    }

                    if($view->langType == 'vn')
                        $strList .=  "<option value='$item->id' $select>$item->name_vn</option>";
                    else
                        $strList .=  "<option value='$item->id' $select>$item->name_en</option>";
                }
            }
            $strList .= '</select>';
        }

        echo $strList;
    }
}

?>
